<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul {
            display: flex;
        }

        li {
            /* float: left; */
            width: 110px;
            list-style: none;
        }
/* 
        .active {
            background-color: pink;
            cursor: pointer;
        } */
    </style>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="(item,index) in arr " :key="item">
                <span :class="index===k?'active':''" @click="change(index,$event)">这是第{{index+1}}张图片</span>
                <span @click="del(index)">删除</span>
            </li>
            <button v-show="k===0?false:true" @click="k--">上一张</button>
            <button v-show="k===arr.length-1?false:true" @click="k++">下一张</button>
        </ul>

        <img :src="arr[k]" alt="">
        <button @click="fn()">按钮</button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                msg: 'ads',
                arr: [
                    '../code练习/imgs/10-01.png',
                    '../code练习/imgs/10-02.png',
                    '../code练习/imgs/11-00.gif',
                    '../code练习/imgs/11-01.gif',
                    '../code练习/imgs/11-02.gif',
                    '../code练习/imgs/11-03.gif',
                    '../code练习/imgs/11-04.png',
                    '../code练习/imgs/11-05.png',
                ],
                k: 0
            },
            methods: {
                fn() {
                    this.k = parseInt(Math.random() * this.arr.length)
                    console.log(this.k)
                },
                change(i, e) {
                    console.log(e)
                    this.k = i
                },
                del(i) {
                    this.arr.splice(i, 1)
                }
            }
        })
        // setInterval(()=>{
        //     app.k++
        // },1000)
    </script>
</body>

</html>